package com.crungoo;

import java.io.IOException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.io.Resource;

/**
 * @author fujc-dev@qq.com
 * @description TODO
 * @date 2023/6/27 13:00
 */

public class 资源加载Programs {

	public static void main(String[] args) throws IOException {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

		Resource resource = context.getResource("file://E:\\MyProjects\\spring-framework-5.3.10\\tuling\\src\\main\\java\\com\\crungoo\\AppConfig.java");
		System.out.println(resource.contentLength());
		System.out.println(resource.getFilename());
		System.out.println(resource.getURL());

		Resource resource1 = context.getResource("https://www.baidu.com");
		System.out.println(resource1.contentLength());
		System.out.println(resource1.getURL());

		Resource resource2 = context.getResource("classpath:spring.xml");
		System.out.println(resource2.contentLength());
		System.out.println(resource2.getURL());
		// Spring内部在什么地方用呢?
		// 获取配置文件
		// 扫描
		Resource[] resources = context.getResources("classpath:com/crungoo/service/*.class");
		for (Resource resource3 : resources) {
			System.out.println(resource3.contentLength());
			System.out.println(resource3.getFilename());
		}
	}
}
